#pragma once

#include "unicode.hpp"

namespace helpers {
namespace text {

template <typename T> 
inline void StringToAny(T &value, const std::string &s)
{
	std::stringstream ss(s);
	ss >> value;
}

template <typename T>
inline T StringToAny(const std::string& str)
{
	T value;
	std::stringstream ss(str);
	ss >> value;
	return value;
}

template <typename T> 
inline std::string AnyToString(T &value)
{
	std::string s;
	std::stringstream ss(s);
	ss << value;
	return ss.str();
}

inline std::string ToString(const std::wstring& src)
{
	const ByteArray& ba = Unicode::fromUtf16(src, UNKNOWN);
	return static_cast<const char*>(ba);
}

inline std::string ToString(wchar_t const * src)
{
	const ByteArray& ba = Unicode::fromUtf16(src, UNKNOWN);
	return static_cast<const char*>(ba);
}

inline std::wstring ToWString(const std::string& src) 
{
	const ByteArray& ba = Unicode::toUtf16(src, UNKNOWN);
	return static_cast<const wchar_t*>(ba);
}

inline std::wstring ToWString(char const * src)
{
	const ByteArray& ba = Unicode::toUtf16(src, UNKNOWN);
	return static_cast<const wchar_t*>(ba);
}


} ///< namespace text
} ///< namespace helpers